//
//  DidGiftView.m
//  GiftItems
//
//  Created by lanou3g on 15/9/18.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "DidGiftView.h"
@implementation DidGiftView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //创建集合视图
        [self setCollectionView];
    }
    return self;
}
//创建集合视图
- (void)setCollectionView{
    //创建一个布局对象
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    //设置集合视图行间距
    layout.minimumLineSpacing = 30;
    //设置每个item之间的间隔
    //layout.minimumInteritemSpacing = (kWidth - 50 - 130 * 2 - 5 * 2) / 2;
    layout.minimumInteritemSpacing = 15;
    //设置每个item的大小
    //layout.itemSize = CGSizeMake(125, 165);
    layout.itemSize = CGSizeMake((kWidth - 50 - 5 * 2 - 15) / 2, (kWidth - 50 - 5 * 2 - 15) / 2 + 40);
    //设置layer的大小
    layout.sectionInset = UIEdgeInsetsMake(10, 5, 80, 5);
    //创建集合视图
    self.collectionV = [[UICollectionView alloc] initWithFrame:CGRectMake(50, 0, kWidth - 50, kHeight - 64) collectionViewLayout:layout];
    self.collectionV.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:self.collectionV];
}
@end

